package com.cowin.inf.controller;

import com.alibaba.fastjson.JSON;
import com.cowin.base.annotation.InterfaceAnnotation;
import com.cowin.base.annotation.LogAnnotation;
import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.inf.model.KyBdcState;
import com.cowin.inf.model.RouteModule;
import com.cowin.inf.model.vo.QueueVo;
import com.cowin.inf.service.KyBdcStateService;
import com.cowin.inf.service.KyVehicleQueueService;
import com.cowin.sys.model.vo.VehicleImpressVo;
import com.cowin.sys.service.TmOfmOrderService;
import com.cowin.sys.service.TmVhcVehicleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Copyright (C), 1998-2019, 奇瑞信息
 *
 * @author : 于超
 * @Date: 2019/11/13 9:02
 * @Description:
 */
@Slf4j
@Api(value = "InfBaseCoreController", description = "基础接口", tags = "InfBaseCoreController", consumes = "application/json")
@RestController
@RequestMapping("inf/mes/core")
public class InfBaseCoreController {
    @Resource
    private TmOfmOrderService tmOfmOrderService;

    @Resource
    private KyBdcStateService kyBdcStateService;

    @Resource
    private KyVehicleQueueService kyVehicleQueueService;

    @PostMapping("/vehicle/impress")
    @ApiOperation(value = "BDC车辆配置信息接口", notes = "BDC车辆配置信息接口")
    @InterfaceAnnotation("BDC_VEHICLE_CONFIG")
    @LogAnnotation("BDC车辆配置信息接口")
    public Result getVehicleImpress(@RequestBody RouteModule routeModule) {
        VehicleImpressVo vehicleImpress = tmOfmOrderService.getVehicleImpress(routeModule.getVin().trim());
        return ResultGenerator.genSuccessResult(vehicleImpress);
    }

    @PostMapping("/bdc/state")
    @InterfaceAnnotation("BDC_LINE_STATE")
    @ApiOperation(value = "BDC状态监控接口", notes = "BDC状态监控接口")
    @LogAnnotation("BDC状态监控接口")
    public Result bdcState(@RequestBody KyBdcState kyBdcState) {
        kyBdcStateService.updateBdcState(kyBdcState);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/bdc/queue")
    @InterfaceAnnotation("BDC_TZ_QUEUE")
    @ApiOperation(value = "BDC涂装总装队列接口", notes = "BDC涂装总装队列接口")
    @LogAnnotation("BDC涂装总装队列接口")
    public Result bdcQueue(@RequestBody QueueVo queueVo) {
        QueueVo result = kyVehicleQueueService.bdcQueue(queueVo);
        return ResultGenerator.genSuccessResult(result);
    }

    @PostMapping("/bdc/queue/bad")
    @InterfaceAnnotation("BDC_QUEUE_BAD")
    @ApiOperation(value = "不满足出库车辆信息接口", notes = "不满足出库车辆信息接口")
    @LogAnnotation("不满足出库车辆信息接口")
    public Result bdcQueueBad(@RequestBody QueueVo queueVo) {
        return ResultGenerator.genSuccessResult(kyVehicleQueueService.bdcQueueBad(queueVo));
    }
}
